// src/stores/userStore.js

class useUserStore {
  private userInfo: API.LoginUser = {
    sex: 0,
    openId: '',
    token: '',
  };
  constructor() {
    let item = localStorage.getItem('userInfo') || undefined;
    let userInfo = item ? JSON.parse(item) : undefined;
    this.userInfo = userInfo;
  }
  getUserInfo = () => {
    return this.userInfo;
  };
  setUserInfo = (userInfo: API.LoginUser) => {
    this.userInfo = userInfo;
    localStorage.setItem('userInfo', JSON.stringify(userInfo));
  };
}

export default useUserStore;
